home *** CD-ROM | disk | FTP | other *** search
/ 100 Plus Great Games 2 / 100PLUSV2.BIN / games / BoxKite.dxr / Internal_62_misc. handlers.ls < prev    next >
Encoding:
Text File  |  2002-01-25  |  5.4 KB  |  192 lines

  1. global foundation, tableau, pootimer, win
  2.  
  3. on createdeck
  4.   facelist = ["ace", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "jack", "queen", "king"]
  5.   unsorted_cards = []
  6.   repeat with h in ["hearts", "diamonds", "clubs", "spades"]
  7.     repeat with i = 1 to 13
  8.       repeat with g = 1 to 2
  9.         unsorted_cards.add([#rank: facelist[i], #suit: h])
  10.       end repeat
  11.     end repeat
  12.   end repeat
  13.   shuffledCards = []
  14.   repeat while unsorted_cards.count > 0
  15.     temp = unsorted_cards[random(unsorted_cards.count)]
  16.     shuffledCards.add(temp)
  17.     unsorted_cards.deleteOne(temp)
  18.   end repeat
  19.   repeat with h in ["ace_hearts", "ace_diamonds", "ace_clubs", "ace_spades", "king_hearts", "king_diamonds", "king_clubs", "king_spades"]
  20.     repeat with u = 1 to shuffledCards.count
  21.       if (shuffledCards[u].rank & "_" & shuffledCards[u].rank) <> h then
  22.         next repeat
  23.       end if
  24.       shuffledCards.deleteAt(u)
  25.       exit repeat
  26.     end repeat
  27.   end repeat
  28.   return shuffledCards
  29. end
  30.  
  31. on makesymbol arg
  32.   return symbol(string(arg))
  33. end
  34.  
  35. on getlist forthis
  36.   if (forthis >= 34) and (forthis <= 45) then
  37.     return tableau[makesymbol(forthis)].cards
  38.   end if
  39.   if (forthis >= 18) and (forthis <= 25) then
  40.     return foundation[makesymbol(forthis)].cards
  41.   end if
  42. end
  43.  
  44. on checklose
  45.   repeat with shit = 34 to 45
  46.     if not sprite(shit).visible then
  47.       next repeat
  48.     end if
  49.     repeat with cakes = 22 to 25
  50.       if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) + 1)) and (getSuit(sprite(shit).member.name) = getSuit(sprite(cakes).member.name)) then
  51.         abort()
  52.       end if
  53.     end repeat
  54.     repeat with cakes = 18 to 21
  55.       if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) - 1)) and (getSuit(sprite(shit).member.name) = getSuit(sprite(cakes).member.name)) then
  56.         abort()
  57.       end if
  58.     end repeat
  59.     repeat with cakes = 34 to 45
  60.       if shit = cakes then
  61.         next repeat
  62.       end if
  63.       if sprite(cakes).visible = 0 then
  64.         next repeat
  65.       end if
  66.       if (not getdup(shit, cakes) and (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) - 1))) or (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) + 1)) or ((getValue(sprite(shit).member.name) = 1) and (getValue(sprite(cakes).member.name) = 13)) or ((getValue(sprite(shit).member.name) = 13) and (getValue(sprite(cakes).member.name) = 1)) then
  67.         abort()
  68.       end if
  69.     end repeat
  70.   end repeat
  71.   repeat with shit = 18 to 25
  72.     if not sprite(shit).visible then
  73.       next repeat
  74.     end if
  75.     repeat with cakes = 34 to 45
  76.       if sprite(cakes).visible = 0 then
  77.         next repeat
  78.       end if
  79.       if (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) - 1)) or (getValue(sprite(shit).member.name) = (getValue(sprite(cakes).member.name) + 1)) or ((getValue(sprite(shit).member.name) = 1) and (getValue(sprite(cakes).member.name) = 13)) or ((getValue(sprite(shit).member.name) = 13) and (getValue(sprite(cakes).member.name) = 1)) then
  80.         abort()
  81.       end if
  82.     end repeat
  83.   end repeat
  84. end
  85.  
  86. on gotoit
  87.   pootimer.forget()
  88.   go("gameover")
  89. end
  90.  
  91. on getValue arg
  92.   if (arg contains "hearts") or (arg contains "spades") then
  93.     return getOff(chars(arg, 1, arg.length - 7))
  94.   else
  95.     if arg contains "diamonds" then
  96.       return getOff(chars(arg, 1, arg.length - 9))
  97.     else
  98.       if arg contains "clubs" then
  99.         return getOff(chars(arg, 1, arg.length - 6))
  100.       end if
  101.     end if
  102.   end if
  103. end
  104.  
  105. on getOff numba
  106.   if numba = "ace" then
  107.     return 1
  108.   else
  109.     if numba = "two" then
  110.       return 2
  111.     else
  112.       if numba = "three" then
  113.         return 3
  114.       else
  115.         if numba = "four" then
  116.           return 4
  117.         else
  118.           if numba = "five" then
  119.             return 5
  120.           else
  121.             if numba = "six" then
  122.               return 6
  123.             else
  124.               if numba = "seven" then
  125.                 return 7
  126.               else
  127.                 if numba = "eight" then
  128.                   return 8
  129.                 else
  130.                   if numba = "nine" then
  131.                     return 9
  132.                   else
  133.                     if numba = "ten" then
  134.                       return 10
  135.                     else
  136.                       if numba = "jack" then
  137.                         return 11
  138.                       else
  139.                         if numba = "queen" then
  140.                           return 12
  141.                         else
  142.                           if numba = "king" then
  143.                             return 13
  144.                           end if
  145.                         end if
  146.                       end if
  147.                     end if
  148.                   end if
  149.                 end if
  150.               end if
  151.             end if
  152.           end if
  153.         end if
  154.       end if
  155.     end if
  156.   end if
  157. end
  158.  
  159. on getSuit arg
  160.   if arg contains "hearts" then
  161.     return #hearts
  162.   else
  163.     if arg contains "diamonds" then
  164.       return #diamonds
  165.     else
  166.       if arg contains "clubs" then
  167.         return #clubs
  168.       else
  169.         if arg contains "spades" then
  170.           return #spades
  171.         end if
  172.       end if
  173.     end if
  174.   end if
  175. end
  176.  
  177. on getdup arg, arg2
  178.   ass = 0
  179.   if tableau[string(arg).symbol].cards.count >= 2 then
  180.     if getOff(tableau[string(arg).symbol].cards[tableau[string(arg).symbol].cards.count - 1].rank) = getValue(sprite(arg2).member.name) then
  181.       ass = 1
  182.     end if
  183.   end if
  184.   if ass = 0 then
  185.     return 0
  186.   end if
  187.   if ass = 1 then
  188.     return 1
  189.   end if
  190.   ass = 0
  191. end
  192.